#include <string> 
#include <iostream>
using namespace std;

string parse(const string &s,int b,int e){
	int n = 0;
	string num;
	for(int i=b+1;s[i]!='|'; i++) num.append(1,s[i]);	
	for(int i=0;i<num.length();i++) n = n*10 + num[i]-'0';
	string ret;
	int rc = 0;
	int lc = 0;
	int first = -1;
	for(int i=b+num.length()+2;i<e; i++){
		if( s[i]=='['){
			rc++; 
			if( first==-1 ) first = i;
		}
		if(rc==0) ret.append(1,s[i]);
		if( s[i]==']') lc++;
		if( rc!=0 && rc==lc ){
			ret.append(parse(s,first,i));
			rc = 0;
			lc = 0;
			first = -1;
		}
	} 
	string t = ret;
	for(int i=0; i<n-1; i++) ret.append(t);
	return ret;
}
int main(){
	string s;
	cin >> s;
	string ss;
	ss.append("[1|");
	ss.append(s);
	ss.append("]");
	cout << parse(ss,0,ss.length()-1);
	return 0;
}
